import request from '@/request/request.js'

// 协议列表
export const userAgreement = (params) => {
	return request({
		url: "/api/qsy/qsy/agreementList",
		method: "post",
		data: params,
	})
}

// 用户登录
export const userLogin = (params) => {
	return request({
		url: "/api/verificat/user/login",
		method: "post",
		data: params,
	})
}

// 修改用户资料
export const userProfile = (params) => {
	return request({
		url: "/api/verificat/user/profile",
		method: "post",
		data: params,
	})
}

// 用户退出登录
export const userLogout = (params) => {
	return request({
		url: "/api/verificat/user/logout",
		method: "post",
		data: params,
	})
}

// 核销记录列表
export const orderList = (params) => {
	return request({
		url: "/api/verificat/order/index",
		method: "post",
		data: params,
	})
}

// 扫码核销
export const orderConfirm = (params) => {
	return request({
		url: "/api/verificat/order/confirm",
		method: "post",
		data: params,
	})
}

// 上传图片
export const commonUpload = (filePath) => {
	const token = uni.getStorageSync('TOKEN')
  return new Promise((resolve) => {
		request({
			url: '/api/wanlshop/common/uploadData',
			method: "post",
			}).then(res=>{
				uni.uploadFile({
					url: res.data.uploadurl,
					filePath: filePath,
					formData: res.data.storage == 'local' ? null : res.data.multipart,
					header: { token: token },
					name: 'file',
					success: data => {
						let info = JSON.parse(data.data)
						resolve(info);
				}
			});
		})
	})
}